﻿using CSScriptLib;
using System;

namespace CSScriptTest
{
    class Program
    {
        static void Main(string[] args)
        {
            MyLibrary.Class1 class1 = new MyLibrary.Class1();
            class1.MyFramworkTest();
            CallFromInternal();
            CallFromScript();
            Console.ReadKey();
        }

        static void CallFromInternal()
        {
            Console.WriteLine("");
            Console.WriteLine("CallFromInternal");
            DateTime beginTime = DateTime.Now;

            HelloWorld hello = new HelloWorld();
            TimeSpan span = DateTime.Now - beginTime;
            Console.WriteLine("create instance timespan: {0}", span);
            beginTime = DateTime.Now;
            hello.SayHello();

            span = DateTime.Now - beginTime;
            Console.WriteLine("call helloWorld timespan: {0}", span);
        }


        static void CallFromScript()
        {
            Console.WriteLine("");
            Console.WriteLine("CallFromScript");
            DateTime beginTime = DateTime.Now;

            dynamic hello = CSScript.Evaluator.LoadFile("HelloWorld.cs") ;
            TimeSpan span = DateTime.Now - beginTime;
            Console.WriteLine("load and precompile script file, timespan= {0}", span);

            beginTime = DateTime.Now;
            hello.SayHello();

            span = DateTime.Now - beginTime;
            Console.WriteLine("call helloWorld timespan: {0}", span);
        }
    }
}
